fix(cli): align strict missing semantics with extract#2512
fix(cli): align strict missing semantics with extract#2512yslpn wants to merge 7 commits intolingui:mainfrom
Conversation
|
@yslpn is attempting to deploy a commit to the Crowdin Team on Vercel. A member of the Team first needs to authorize it. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2512 +/- ##
===========================================
+ Coverage 77.05% 89.27% +12.22%
===========================================
Files 84 118 +34
Lines 2157 3421 +1264
Branches 555 1026 +471
===========================================
+ Hits 1662 3054 +1392
+ Misses 382 331 -51
+ Partials 113 36 -77 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Aligns the definition of “missing translations” across lingui extract, lingui compile --strict, and bundler integrations (failOnMissing) so that strict checks are based on raw missing entries in the target locale catalog (ignoring fallbackLocales), while compiled output fallback behavior remains unchanged. This addresses issue #2506.
Changes:
- Introduces
missingBehavior: "catalog"to count missing translations based on the target locale’s catalog entries (not post-fallback resolution). - Updates CLI compile flow + webpack loader + Vite plugin to use the new missing semantics for strict/fail-on-missing validation.
- Adds regression tests/fixtures for CLI, webpack loader, and Vite plugin; updates CLI docs wording.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/ref/cli.md | Updates compile --strict documentation to describe pre-fallbackLocales missing semantics. |
| packages/cli/src/lingui-compile.ts | Updates CLI --strict option description text. |
| packages/cli/src/api/compile/compileLocale.ts | Forces strict missing detection to use raw catalog semantics via missingBehavior: "catalog". |
| packages/cli/src/api/catalog/getTranslationsForCatalog.ts | Adds missingBehavior option and implements raw-vs-resolved missing detection. |
| packages/cli/src/api/catalog/getTranslationsForCatalog.test.ts | Adds test coverage for raw missing detection even when fallbacks resolve. |
| packages/cli/src/test/compile.test.ts | Adds CLI regression test for strict failure despite fallback resolution. |
| packages/cli/src/test/snapshots/compile.test.ts.snap | Updates snapshots impacted by the changed strict/missing semantics. |
| packages/loader/src/webpackLoader.ts | Aligns loader failOnMissing behavior with raw catalog missing semantics. |
| packages/loader/test/loader.test.ts | Adds loader regression test for fallback-resolved but raw-missing translations. |
| packages/loader/test/fail-on-missing-fallback/** | Adds loader fixture catalogs/config for fallback-missing scenario. |
| packages/vite-plugin/src/index.ts | Aligns Vite plugin failOnMissing behavior with raw catalog missing semantics. |
| packages/vite-plugin/test/vite-plugin.test.ts | Adds Vite regression test for fallback-resolved but raw-missing translations (and adjusts timeouts). |
| packages/vite-plugin/test/fail-on-missing-fallback/** | Adds Vite fixture catalogs/config for fallback-missing scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Since this wasn't released with v6, and it is a breaking change now, i propose to make it non-breaking by hiding behind a feature flag. You can use current strict flag, or add a more dedicated such as WDYT? |
Then I think I'll add two modes with this interface: // CLI
--strict // resolved + compile errors
--fail-on-missing resolved // resolved only
--fail-on-missing catalog // catalog only
--strict --fail-on-missing catalog // catalog + compile errors
--strict --fail-on-missing resolved // resolved + compile errors
// webpack / vite
failOnMissing: true // resolved
failOnMissing: "resolved" // resolved
failOnMissing: "catalog" // catalog |
Description
This change makes missing-translation validation configurable while preserving the existing Lingui 6 behavior by default.
It closes issue #2506.
Previously, the proposed fix changed
compile --strictand bundlerfailOnMissingsemantics to validate raw target catalog entries beforefallbackLocaleswere applied. That matchedextractmissing counts, but it would now be a breaking change for users who rely on fallback-resolved catalogs passing strict validation.With this change:
compile --strictkeeps the existing resolved behavior and still fails on message compilation errors.compile --fail-on-missing resolvedfails only when translations are still missing afterfallbackLocalesare applied.compile --fail-on-missing catalogfails when the target locale catalog itself has missing translations beforefallbackLocalesare applied.compile --strict --fail-on-missing catalogcombines catalog-level missing validation with compilation error validation.failOnMissing: truekeep the existing resolved behavior.failOnMissing: "resolved"andfailOnMissing: "catalog"provide explicit missing-validation modes.This gives teams a non-breaking way to opt into catalog-level missing validation, while keeping current
--strictandfailOnMissing: truebehavior compatible with existing projects.Types of changes
Fixes #2506
Checklist